package com.kiln.juxingqs.ui

import android.content.Intent
import android.text.TextUtils
import androidx.lifecycle.Observer
import client.global.commlib.dialog.SelectAddrDialog
import client.global.commlib.toast.toast
import com.kiln.juxingqs.BaseMiddleActivity
import com.kiln.juxingqs.R
import com.kiln.juxingqs.ui.vm.DePayViewModel
import com.kiln.juxingqs.api.bean.UserAddress
import com.kiln.juxingqs.databinding.ActivityDepayBinding

class DePayActivity : BaseMiddleActivity<DePayViewModel, ActivityDepayBinding>() {

    override fun getLayout(): Int {
        return R.layout.activity_depay
    }

    override fun initViewModel(): DePayViewModel = createViewModel()

    override fun initView() {
        binding?.apply {
            event = this@DePayActivity
            vm = viewModel

        }

        viewModel.num.value = intent.getStringExtra("num")
        viewModel.txType.value = intent.getIntExtra("txType", 0)
    }

    override fun observerUI() {
        viewModel.call.observe(this, Observer {
            it?.apply {
                if (it.isSuccess) {
                    startActivity(Intent(this@DePayActivity, DePayShowActivity::class.java).apply {
                        putExtra("remark", it.data!!.oid)
                        putExtra("price", it.data!!.price)

                    })
                    finish()
                }
            }
        })
    }

}